<?php

namespace app\api\controller;

use think\Controller;
use think\Db;

// md 获取 为了辅助 
class Mkfz extends Controller
{
    public function index()
    {



        $dh ="NJ03-Y-WS-W1955-001-005";
        // get 发出请求 获取 档案信息
        $url = 'http://192.168.137.171:8082/api/Markdown/index?dh='.$dh;
        
        // 使用curl代替Http类
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        $response = curl_exec($ch);
        curl_close($ch);
        
        $data = json_decode($response, true);

        if(empty( $data['data'])){
            return array("code"=>200,"msg"=>"获取档案信息失败");
        }

        $insertArray = array();

        foreach($data['data'] as $k=>$v){
           
            $insertArray[] = array(
                "dh"=>$dh ,
                "qzh"=>"NJ03",
                "text"=>$v,
            );
        }

        Db::table('zstp_obtain_queue_mk')->insertAll($insertArray);

    }
}